﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登录页</title>
    <link href="css/style1.css" rel="stylesheet" />
    <link href="../Ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    <script src="../Ext/ext-all.js" type="text/javascript"></script>
    <script type="text/javascript">

        function Tuichu() {
            Ext.util.Cookies.clear("userName");
            Ext.Ajax.request({
                method: "POST",
                url: "../usercheck?format=json"
            })

        }

        function strdown(event) {
            if (event.keyCode == 13) {
                Save();
            }
        }
        function Save() {
            var name = document.getElementById("userName").value;
            var pwd = document.getElementById("userPwd").value;

            if (name == "" || name == null) {
                Ext.Msg.alert("提示信息", "用户名不能为空");
                return;
            }
            if (pwd == "" || pwd == null) {
                Ext.Msg.alert("提示信息", "密码不能为空");
                return;
            }
            Ext.Ajax.request({
                method: "POST",
                url: encodeURI("../api/usercheck?format=json&userName=" + name + "&userPwd=" + pwd),
                success: function (response, options) {
                    var obj = eval("[" + response.responseText + "]");
                    var msg = obj[0].ResponseStatus.Message;
                    if (msg == "" || msg == null) {
                        Ext.util.Cookies.set('userName', name);

                        window.location.href = "../index.htm";
                    } else if (msg == "1") {
                        Ext.Msg.alert("提示信息", "请输入正确的密码！");
                    } else if (msg == "0") {
                        Ext.Msg.alert("提示信息", "用户名无效！");
                    } else if (msg == "2") {
                        Ext.Msg.alert("提示信息", "此用户已被锁定了，请联系管理员！");
                    }

                },
                failure: function (response, options) {
                    Ext.Msg.alert('错误', '状态:' + response.status + ': ' + response.statusText);
                    return;

                }
            })
        }

        function Clear() {
            var name = document.getElementById("userName");
            var pwd = document.getElementById("userPwd");
            name.value = "";
            pwd.value = "";
        }
    </script>
</head>
<body onload="Tuichu();">
    <div id="bh-wzm-login-all">
        <div class="bh-wzm-center">
            <a href="#">
                <img src="img/logo1.png" /></a>
            <p class="bh-wzm-huanying">
                欢迎使用人力资源外包管理系统</p>
            <div class="bh-wzm-table">
                <table width="200" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td style="color: #48596d" width="60" align="right">
                            用户：
                        </td>
                        <td colspan="2" width="120">
                            <input type="text" class="bh-wzm-yonhu" id="userName" />
                        </td>
                    </tr>
                    <tr>
                        <td style="color: #48596d" width="60" align="right">
                            密码：
                        </td>
                        <td colspan="2">
                            <input type="password" class="bh-wzm-yonhu" id="userPwd" onkeyup="strdown(event)" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <input type="submit" value="登录" class="bh-wzm-dlu" id="Button1" onclick="Save()" />
                        </td>
                        <td>
                            <input type="submit" value="重置" class="bh-wzm-dlu" onclick="Clear()" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <!-- <td colspan="2"><input name="" type="radio" value="" />记住密码？</td>-->
                    </tr>
                </table>
            </div>
            <p class="bh-wzm-copyright">
                版权所有：北京六和新创科技有限公司</p>
        </div>
    </div>
</body>
</html>
